<?php
/**
 * 物件一覧基底クラス<br />
 *
 * @package apamanshop
 * @author SS永田
 * @copyright コピーライト(要確認)
 */
abstract class Rstobi_Model_Base extends Apm_Model_Base
{
	/**
	/* 初期処理
	 */
	public function __construct()
	{
		// インスタンス生成
		$this->_model_rstobi_common  = new Rstobi_Model_Common();  //共通クラス（物件一覧）
    	$loader = new Zend_Application_Module_Autoloader(array(
			'namespace' => 'Search',
			'basePath' => APPLICATION_PATH . '/modules/search',
		));
		$this->_model_search_common  = new Search_Model_Common();  //共通クラス（検索導線）
	}

	/*
	/* ROW_NUMBERの取得
	/*
	/* @access private
	/* @param  array
	/* @return string
	 */
	private function getRownumber($params)
	{
		$rownumber  = ' ROW_NUMBER() OVER (partition by T03.T03_ORIGINAL_HEYA_CD01,T03.T03_KASHIDASHI_KUBUN ';

		// OEMの場合は、店別の条件で分ける（企業の物件検索対応）
		if($this->_model_rstobi_common->isOem($params))
		{
			$rownumber .= '                            ,T03_TEN_FREERENT_FLAG';
			$rownumber .= '                            ,T03_TEN_FREERENT_KIGEN';
			$rownumber .= '                            ,T03_TEN_FREERENT_TSUKISUU';
			$rownumber .= '                            ,T03_TEN_HEYAWARI_FLAG';
		}

		$rownumber .= '              ORDER BY';
		$rownumber .= '                         T03.T03_MOTODUKE_FLAG DESC';
		$rownumber .= '                        ,T03.T03_TENPO_DISTANCE) as T03_HEYA_ROW';

		return $rownumber;
	}

	/*
	/* ヒント句の取得
	/*
	/* @access private
	/* @param  array
	/* @return string
	 */
	private function getQryhint($params)
	{
		//ヒント句を記述する場合は、ここに記述
		$qryhint = "";
		$$parallel = "";

		// 住所検索
		if($params['SrhKbn']  == Apm_Config_Search::SRHKBN_JYUSYO  ||
		   $params['SrhType'] == Apm_Config_Search::SRHTYPE_JYUSYO ||
		   $params['SrhKbn']  == Apm_Config_Search::SRHKBN_JYUKYOKEITAI )
		{
			$qryhint = " /*+ INDEX(T03 IDX_T03WEB_HEYA_SEARCH12)  */ ";
		}
		// 沿線・駅、住みたい駅、路線図検索
		else if($params['SrhKbn']  == Apm_Config_Search::SRHKBN_ENSENEKI    ||
				$params['SrhKbn']  == Apm_Config_Search::SRHKBN_ROSENZU     ||
				$params['SrhKbn']  == Apm_Config_Search::SRHKBN_SUMITAIEKI  ||
				$params['SrhKbn']  == Apm_Config_Search::SRHKBN_TUKINTUGAKU ||
				$params['SrhType'] == Apm_Config_Search::SRHTYPE_ENSENEKI)
		{
			// 複数沿線、駅の場合は、多重化
			if($this->_params['RstobiDispType'] <> Apm_Config_Search::LISTTYPE_SHOP &&
			   (count($params['StCd'])   > 2 ||
			   (count($params['RailCd']) > 2 && !array_key_exists('StCd', $params))))
			{
				$parallel = " PARALLEL (T03,3) ";
			}

			$qryhint = " /*+ ".$parallel." INDEX(T03 IDX_T03WEB_HEYA_SEARCH24_1 ) INDEX(T03 IDX_T03WEB_HEYA_SEARCH24_2) INDEX(T03 IDX_T03WEB_HEYA_SEARCH24_3) */ ";
		}

		return $qryhint;
	}

	/*
	/* 物件一覧用SELECT句の取得
	/*
	/* @access public
	/* @param  param
	/* @return string
	 */
	public function getSelectPhraseForBuken($params)
	{
		// ｸｴﾘ文字列（Select句）
//		$strQrySelect .= ' SELECT /*+ FIRST_ROWS(501) */';
		$strQrySelect .= ' SELECT ';
		$strQrySelect .= '     T03.* ';
		// 2011/04/18 #352:災害時特別優遇物件 End
		// 2011/4/12 #351:家電部屋キャンペーン対応 Start
		/*
		 * 家電部屋キャンペーンICON対応、キャンペーン終了次第削除する。
		 */
		if($params['SrhKbn'] <> Apm_Config_Search::SRHKBN_JYOHOSHINO)
		{

			$strQrySelect .= Apm_Bukkenitems::getSelectPhraseForDisplayIconCampaign($params);
		}
		// 2011/4/12 #351:家電部屋キャンペーン対応 End		
		$strQrySelect .= ' FROM';
		$strQrySelect .= '    (SELECT';
		$strQrySelect .= '         ROWNUM AS T03_DISP_ROW,';
		$strQrySelect .= '         T03_HEYA.*';
		$strQrySelect .= '     FROM';
//		$strQrySelect .= '        (SELECT';
//		$strQrySelect .= '        (SELECT distinct';
//		$strQrySelect .= '             *';
//		$strQrySelect .= '         FROM';
		$strQrySelect .= '             (SELECT';
		$strQrySelect .= $this->getQryhint($params);
//		$strQrySelect .= $this->getRownumber($params);
//		$strQrySelect .= '                ,T03.T03_HEYA_CD';
		// UPDATE 2011/09/14 H.Imamura レスポンス改善：キャンペーン検索を等結合するため、常にdistinctをかける。
		//if($params['SrhKbn'] != Apm_Config_Search::SRHKBN_JYUSYO)
		//{
			$strQrySelect .= '             distinct';
		//}
		$strQrySelect .= '                 T03.T03_HEYA_CD';
		$strQrySelect .= '                ,T03.T03_TATEMONO_CD';
		$strQrySelect .= '                ,T03.T03_TENPO_CD';
		$strQrySelect .= '                ,T03.T03_ORIGINAL_TATEMONO_CD01';
		$strQrySelect .= '                ,T03.T03_ORIGINAL_TATEMONO_CD02';
		$strQrySelect .= '                ,T03.T03_ORIGINAL_HEYA_CD01';
		$strQrySelect .= '                ,T03.T03_ORIGINAL_HEYA_CD02';
		$strQrySelect .= '                ,T03.T03_TODOUFUKEN_CD';
		$strQrySelect .= '                ,T03.T03_SHIKUCHOUSON_CD';
		$strQrySelect .= '                ,T03.T03_SHIKUCHOUSON';
		$strQrySelect .= '                ,T03.T03_CHOUMEI_CD';
		$strQrySelect .= '                ,T03.T03_CHOUMOKU_CD';
		$strQrySelect .= '                ,T03.T03_JYUUSHO_TEXT';
		$strQrySelect .= '                ,T03.T03_BANCHI';
		$strQrySelect .= '                ,T03.T03_ANNAI_MAP_USE_FLAG';
		$strQrySelect .= '                ,T03.T03_TATEMONO_TYPE_CD';
		$strQrySelect .= '                ,T03.T03_TATEMONO_TYPE';
		$strQrySelect .= '                ,T03.T03_TATEMONO_KOUZOU_CD';
		$strQrySelect .= '                ,T03.T03_TATEMONO_KOUZOU';
		$strQrySelect .= '                ,T03.T03_KAIDATE';
		$strQrySelect .= '                ,T03.T03_KOSUU';
		$strQrySelect .= '                ,T03.T03_KANSEINEN';
		$strQrySelect .= '                ,T03.T03_KANSEITSUKI';
		$strQrySelect .= '                ,T03.T03_KANSEIBI';
		$strQrySelect .= '                ,T03.T03_SHINCHIKU_FLAG';
		$strQrySelect .= '                ,T03.T03_TATEMONO_MENSEKI';
		$strQrySelect .= '                ,T03.T03_SHIKICHI_MENSEKI';
		$strQrySelect .= '                ,T03.T03_KAI';
		$strQrySelect .= '                ,T03.T03_HOUGAKU';
		$strQrySelect .= '                ,T03.T03_MADORI_CD';
		$strQrySelect .= '                ,T03.T03_MADORI';
		$strQrySelect .= '                ,T03.T03_SENYUU_MENSEKI';
		$strQrySelect .= '                ,T03.T03_YACHIN';
		$strQrySelect .= '                ,T03.T03_YACHIN_TAX';
		$strQrySelect .= '                ,T03.T03_KANRIHI';
		$strQrySelect .= '                ,T03.T03_KANRIHI_TAX';
		$strQrySelect .= '                ,T03.T03_KYOUEKIHI';
		$strQrySelect .= '                ,T03.T03_KYOUEKIHI_TAX';
		$strQrySelect .= '                ,T03.T03_SHIKIKIN';
		$strQrySelect .= '                ,T03.T03_REIKIN';
		$strQrySelect .= '                ,T03.T03_HOSHOUKIN';
		$strQrySelect .= '                ,T03.T03_SHOUKYAKU_KUBUN';
		$strQrySelect .= '                ,T03.T03_SHOUKYAKUKIN';
		$strQrySelect .= '                ,T03.T03_KOUSHINRYOU';
		$strQrySelect .= '                ,T03.T03_SHIKIKIN_TSUKISUU';
		$strQrySelect .= '                ,T03.T03_REIKIN_TSUKISUU';
		$strQrySelect .= '                ,T03.T03_HOSHOUKIN_TSUKISUU';
		$strQrySelect .= '                ,T03.T03_SHOUKYAKUKIN_TSUKISUU';
		$strQrySelect .= '                ,T03.T03_SHOUKYAKUKINRITSU';
		$strQrySelect .= '                ,T03.T03_KOUSHINRYOUTSUKISUU';
		$strQrySelect .= '                ,T03.T03_TESUURYOU_FLAG';
		$strQrySelect .= '                ,T03.T03_KOUSHINRYOU_FLAG';
		$strQrySelect .= '                ,T03.T03_NYUUKYO_NEN';
		$strQrySelect .= '                ,T03.T03_NYUUKYO_TSUKI';
		$strQrySelect .= '                ,T03.T03_NYUUKYO_ZIKI';
		$strQrySelect .= '                ,T03.T03_KOUTSUU_CD01';
		$strQrySelect .= '                ,T03.T03_ENSEN_CD01';
		$strQrySelect .= '                ,T03.T03_ENSEN_NAME';
		$strQrySelect .= '                ,T03.T03_EKI_CD01';
		$strQrySelect .= '                ,T03.T03_EKI_NAME';
		$strQrySelect .= '                ,T03.T03_BUS_GAISHA';
		$strQrySelect .= '                ,T03.T03_BUS_JYOUSHA';
		$strQrySelect .= '                ,T03.T03_BUS_STOP';
		$strQrySelect .= '                ,T03.T03_TOHO01';
		$strQrySelect .= '                ,T03.T03_KOUTSUU_BIKOU01';
		$strQrySelect .= '                ,T03.T03_KOUTSUU_TEXT01';
		$strQrySelect .= '                ,T03.T03_RENRAKU_EKI_CD01';
		$strQrySelect .= '                ,T03.T03_KOUTSUU_CD02';
		$strQrySelect .= '                ,T03.T03_ENSEN_CD02';
		$strQrySelect .= '                ,T03.T03_ENSEN_NAME02';
		$strQrySelect .= '                ,T03.T03_EKI_CD02';
		$strQrySelect .= '                ,T03.T03_EKI_NAME02';
		$strQrySelect .= '                ,T03.T03_BUS_GAISHA02';
		$strQrySelect .= '                ,T03.T03_BUS_JYOUSHA02';
		$strQrySelect .= '                ,T03.T03_BUS_STOP02';
		$strQrySelect .= '                ,T03.T03_TOHO02';
		$strQrySelect .= '                ,T03.T03_KOUTSUU_BIKOU02';
		$strQrySelect .= '                ,T03.T03_KOUTSUU_TEXT02';
		$strQrySelect .= '                ,T03.T03_RENRAKU_EKI_CD02';
		$strQrySelect .= '                ,T03.T03_KOUTSUU_CD03';
		$strQrySelect .= '                ,T03.T03_ENSEN_CD03';
		$strQrySelect .= '                ,T03.T03_ENSEN_NAME03';
		$strQrySelect .= '                ,T03.T03_EKI_CD03';
		$strQrySelect .= '                ,T03.T03_EKI_NAME03';
		$strQrySelect .= '                ,T03.T03_BUS_GAISHA03';
		$strQrySelect .= '                ,T03.T03_BUS_JYOUSHA03';
		$strQrySelect .= '                ,T03.T03_BUS_STOP03';
		$strQrySelect .= '                ,T03.T03_TOHO03';
		$strQrySelect .= '                ,T03.T03_KOUTSUU_BIKOU03';
		$strQrySelect .= '                ,T03.T03_KOUTSUU_TEXT03';
		$strQrySelect .= '                ,T03.T03_RENRAKU_EKI_CD03';
		$strQrySelect .= '                ,T03.T03_GAIKAN_GAZOU01';
		$strQrySelect .= '                ,T03.T03_GAIKAN_GAZOU02';
		$strQrySelect .= '                ,T03.T03_GAIKAN_GAZOU03';
		$strQrySelect .= '                ,T03.T03_GAIKAN_GAZOU04';
		$strQrySelect .= '                ,T03.T03_GAIKAN_GAZOU05';
		//$strQrySelect .= '                ,T03.T03_HAICHIZU';
		$strQrySelect .= '                ,T03.T03_SHUHEN_GAZOU01';
		$strQrySelect .= '                ,T03.T03_SHUHEN_GAZOU02';
		$strQrySelect .= '                ,T03.T03_NAISOU_GAZOU01';
		$strQrySelect .= '                ,T03.T03_NAISOU_GAZOU02';
		$strQrySelect .= '                ,T03.T03_NAISOU_GAZOU03';
		$strQrySelect .= '                ,T03.T03_NAISOU_GAZOU04';
		$strQrySelect .= '                ,T03.T03_NAISOU_GAZOU05';
		$strQrySelect .= '                ,T03.T03_NAISOU_GAZOU06';
		$strQrySelect .= '                ,T03.T03_NAISOU_GAZOU07';
		$strQrySelect .= '                ,T03.T03_NAISOU_GAZOU08';
		$strQrySelect .= '                ,T03.T03_NAISOU_GAZOU09';
		$strQrySelect .= '                ,T03.T03_NAISOU_GAZOU10';
		$strQrySelect .= '                ,T03.T03_MADORIZU';
		//$strQrySelect .= '                ,T03.T03_PANORAMA_GAZOU01';
		//$strQrySelect .= '                ,T03.T03_PANORAMA_GAZOU02';
		$strQrySelect .= '                ,T03.T03_TOUROKUBI';
		$strQrySelect .= '                ,T03.T03_TOUROKUBI_STR';
		$strQrySelect .= '                ,T03.T03_SAKUSEIBI';
		$strQrySelect .= '                ,T03.T03_KOUSHINBI';
		$strQrySelect .= '                ,T03.T03_FREERENT_FLAG';
		$strQrySelect .= '                ,T03.T03_HEYAWARI_FLAG';
		$strQrySelect .= '                ,T03.T03_MEYASU_CHINRYO';
		$strQrySelect .= '                ,T03.T03_TEN_MEYASU_CHINRYO';
		$strQrySelect .= '                ,T03.T03_GAIKAN_GAZOU_COMMON01';
		$strQrySelect .= '                ,T03.T03_GAIKAN_GAZOU_COMMON02';
		$strQrySelect .= '                ,T03.T03_GAIKAN_GAZOU_COMMON03';
		$strQrySelect .= '                ,T03.T03_GAIKAN_GAZOU_COMMON04';
		$strQrySelect .= '                ,T03.T03_GAIKAN_GAZOU_COMMON05';
		$strQrySelect .= '                ,T03.T03_HAICHIZU_COMMON';
		$strQrySelect .= '                ,T03.T03_SHUHEN_GAZOU_COMMON01';
		$strQrySelect .= '                ,T03.T03_SHUHEN_GAZOU_COMMON02';
		$strQrySelect .= '                ,T03.T03_NAISOU_GAZOU_COMMON01';
		$strQrySelect .= '                ,T03.T03_NAISOU_GAZOU_COMMON02';
		$strQrySelect .= '                ,T03.T03_NAISOU_GAZOU_COMMON03';
		$strQrySelect .= '                ,T03.T03_NAISOU_GAZOU_COMMON04';
		$strQrySelect .= '                ,T03.T03_NAISOU_GAZOU_COMMON05';
		$strQrySelect .= '                ,T03.T03_NAISOU_GAZOU_COMMON06';
		$strQrySelect .= '                ,T03.T03_NAISOU_GAZOU_COMMON07';
		$strQrySelect .= '                ,T03.T03_NAISOU_GAZOU_COMMON08';
		$strQrySelect .= '                ,T03.T03_NAISOU_GAZOU_COMMON09';
		$strQrySelect .= '                ,T03.T03_NAISOU_GAZOU_COMMON10';
		$strQrySelect .= '                ,T03.T03_MADORIZU_COMMON';
		$strQrySelect .= '                ,T03.T03_PANORAMA_GAZOU_COMMON01';
		$strQrySelect .= '                ,T03.T03_PANORAMA_GAZOU_COMMON02';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU01';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU_TYPE01';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU02';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU_TYPE02';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU03';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU_TYPE03';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU04';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU_TYPE04';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU05';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU_TYPE05';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU06';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU_TYPE06';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU07';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU_TYPE07';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU08';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU_TYPE08';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU09';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU_TYPE09';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU10';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU_TYPE10';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU11';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU_TYPE11';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU12';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU_TYPE12';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU_COMMON01';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU_TYPE_COMMON01';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU_COMMON02';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU_TYPE_COMMON02';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU_COMMON03';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU_TYPE_COMMON03';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU_COMMON04';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU_TYPE_COMMON04';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU_COMMON05';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU_TYPE_COMMON05';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU_COMMON06';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU_TYPE_COMMON06';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU_COMMON07';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU_TYPE_COMMON07';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU_COMMON08';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU_TYPE_COMMON08';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU_COMMON09';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU_TYPE_COMMON09';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU_COMMON10';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU_TYPE_COMMON10';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU_COMMON11';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU_TYPE_COMMON11';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU_COMMON12';
		$strQrySelect .= '                ,T03.T03_FREE_GAZOU_TYPE_COMMON12';
		// 2014/04/28 Add H.Imamura 内装画像種別追加 Start
		$strQrySelect .= '                ,T03.T03_NAISOU_GAZOU_TYPE01';
		$strQrySelect .= '                ,T03.T03_NAISOU_GAZOU_TYPE02';
		$strQrySelect .= '                ,T03.T03_NAISOU_GAZOU_TYPE03';
		$strQrySelect .= '                ,T03.T03_NAISOU_GAZOU_TYPE04';
		$strQrySelect .= '                ,T03.T03_NAISOU_GAZOU_TYPE05';
		$strQrySelect .= '                ,T03.T03_NAISOU_GAZOU_TYPE06';
		$strQrySelect .= '                ,T03.T03_NAISOU_GAZOU_TYPE07';
		$strQrySelect .= '                ,T03.T03_NAISOU_GAZOU_TYPE08';
		$strQrySelect .= '                ,T03.T03_NAISOU_GAZOU_TYPE09';
		$strQrySelect .= '                ,T03.T03_NAISOU_GAZOU_TYPE10';
		// 2014/04/28 Add H.Imamura 内装画像種別追加 End
		$strQrySelect .= '                ,T03.T03_YACHIN_KANRI_KYOEKI_SUM';
		$strQrySelect .= '                ,T03.T03_TIKU_NENSU';
		$strQrySelect .= '                ,CASE WHEN (( (sysdate - 7) < T03.T03_KOUSHINBI ) AND ( T03.T03_KIGENGIRE_SHUUSEI_FLAG <> 1 )) THEN 0 ELSE 1 END AS SHINCHAKU_FLAG';
		$strQrySelect .= '                ,T03.T03_SHATAKU_TEKIYOU_FLAG';
		$strQrySelect .= '                ,T03.T03_KASHIDASHI_KUBUN';
		$strQrySelect .= '                ,T03.T03_SHOKI_HIYO';
		$strQrySelect .= '                ,T03.T03_TEN_SHOKI_HIYO';
		$strQrySelect .= '                ,T03.T03_KOUKOKU_KAISHA_CD';
		$strQrySelect .= '                ,T03.T03_KOUKOKU_TOIAWASE_NO';
		$strQrySelect .= '                ,T03.T03_MOTODUKE_FLAG';
		$strQrySelect .= '                ,T03.T03_TENPO_DISTANCE';
		$strQrySelect .= '                ,T03.T03_TEN_HEYAWARI_FLAG';
		$strQrySelect .= '                ,T03.T03_PR01';
		$strQrySelect .= '                ,T03.T03_PR02';
		$strQrySelect .= '                ,T03.T03_TEN_FREERENT_FLAG';
//		$strQrySelect .= '                ,CEIL(DBMS_RANDOM.VALUE*1000000) RANDOM';		// ランダム表示対応
		$strQrySelect .= '                ,(CASE WHEN NVL(T03_TEN_MEYASU_CHINRYO,0) != 0 THEN T03_TEN_MEYASU_CHINRYO ELSE DECODE(NVL(T03_MEYASU_CHINRYO,0),0,9999999,T03_MEYASU_CHINRYO) END) AS T03_SORT_MEYASU_CHINRYO';
		$strQrySelect .= '                ,(CASE WHEN NVL(T03_TEN_MEYASU_CHINRYO,0) != 0 THEN T03_TEN_MEYASU_CHINRYO ELSE DECODE(NVL(T03_MEYASU_CHINRYO,0),0,0,T03_MEYASU_CHINRYO) END) AS T03_SORT_MEYASU_CHINRYO_DESC';
		// 2011/3/30 #344:災害支援住宅対応 Start
		$strQrySelect .= '                ,T03.T03_SAIGAI_HUTU_KBN';
		$strQrySelect .= '                ,T03.T03_SAIGAI_TEIKI_FLG';
		// 2011/3/30 #344:災害支援住宅対応 End
		// 2011/04/18 #352:災害時特別優遇物件 Start
		$strQrySelect .= '                ,T03.T03_SAIGAI_YUGU_FLAG';
		// 2013/02/05 Add Start 関連情報のためカラム取得しておく
		$strQrySelect .= '                ,T03.T03_NYUUKYO_JYOUKEN01';
		$strQrySelect .= '                ,T03.T03_NYUUKYO_JYOUKEN02';
		$strQrySelect .= '                ,T03.T03_NYUUKYO_JYOUKEN03';
		//$strQrySelect .= '                ,T03.T03_NYUUKYO_JYOUKEN04';
		//$strQrySelect .= '                ,T03.T03_NYUUKYO_JYOUKEN05';
		$strQrySelect .= '                ,T03.T03_NYUUKYO_JYOUKEN06';
		//$strQrySelect .= '                ,T03.T03_NYUUKYO_JYOUKEN07';
		//$strQrySelect .= '                ,T03.T03_NYUUKYO_JYOUKEN08';
		$strQrySelect .= '                ,T03.T03_NYUUKYO_JYOUKEN09';
		//$strQrySelect .= '                ,T03.T03_NYUUKYO_JYOUKEN10';
		//$strQrySelect .= '                ,T03.T03_NYUUKYO_JYOUKEN11';
		//$strQrySelect .= '                ,T03.T03_NYUUKYO_JYOUKEN12';
		//$strQrySelect .= '                ,T03.T03_NYUUKYO_JYOUKEN13';
		$strQrySelect .= '                ,T03.T03_SETSUBI02';
		$strQrySelect .= '                ,T03.T03_SETSUBI03';
		$strQrySelect .= '                ,T03.T03_SETSUBI09';
		$strQrySelect .= '                ,T03.T03_SETSUBI13';
		$strQrySelect .= '                ,T03.T03_SETSUBI14';
		$strQrySelect .= '                ,T03.T03_SETSUBI31';
		$strQrySelect .= '                ,T03.T03_SETSUBI32';
		$strQrySelect .= '                ,T03.T03_SETSUBI34';
		$strQrySelect .= '                ,T03.T03_SETSUBI35';
		$strQrySelect .= '                ,T03.T03_SETSUBI43';
		$strQrySelect .= '                ,T03.T03_SETSUBI47';
		$strQrySelect .= '                ,T03.T03_SETSUBI51';
		$strQrySelect .= '                ,T03.T03_SETSUBI57';
		$strQrySelect .= '                ,T03.T03_SETSUBI60';
		$strQrySelect .= '                ,T03.T03_SETSUBI63';
		$strQrySelect .= '                ,T03.T03_SETSUBI64';
		$strQrySelect .= '                ,T03.T03_SETSUBI65';
		$strQrySelect .= '                ,T03.T03_SETSUBI66';
		$strQrySelect .= '                ,T03.T03_SETSUBI71';
		$strQrySelect .= '                ,T03.T03_CHUUSHAJYOU_KUBUN';
		$strQrySelect .= '                ,T03.T03_HOSHOUNIN_FLAG';
		$strQrySelect .= '                ,T03.T03_HEYA_JYOUKYOU';
		// 2013/02/05 Add End

		return $strQrySelect;
	}


	/*
	/* 物件一覧 カウント用SELECT句の取得
	/*
	/* @access public
	/* @return string
	 */
	public function getSelectCountForBuken($params)
	{

		// ｸｴﾘ文字列（Select句）
		$strQrySelect .= ' SELECT ';
		$strQrySelect .= '     count(*) AS BUKEN_COUNT ';
		$strQrySelect .= ' FROM ';
//		$strQrySelect .= '     (SELECT ';
		$strQrySelect .= '     (SELECT ';
		$strQrySelect .= $this->getQryhint($params);
		// UPDATE 2011/09/14 H.Imamura レスポンス改善：キャンペーン検索を等結合するため、常にdistinctをかける。
		//if($params['SrhKbn'] != Apm_Config_Search::SRHKBN_JYUSYO)
		//{
			$strQrySelect .= '          distinct ';
		//}
//		$strQrySelect .= '          T03_HEYA_CD';
//		$strQrySelect .= '         ,T03_ORIGINAL_HEYA_CD01';
//		$strQrySelect .= '         ,T03_KASHIDASHI_KUBUN';
		$strQrySelect .= '          T03.T03_HEYA_CD';
//		$strQrySelect .= '         ,T03.T03_ORIGINAL_HEYA_CD01';
//		$strQrySelect .= '         ,T03.T03_KASHIDASHI_KUBUN';

		return $strQrySelect;
	}

	/*
	/* WHERE句の最終行を取得
	/*
	/* @access public
	/* @return string
	 */
	public function getWhereEndForBuken()
	{
		$sql  = ') T03 ';
		//$sql .= ' where';
		//$sql .= ' T03_HEYA_ROW = 1';

		return $sql;
	}

	/*
	/* Betweenを取得する
	/*
	/* @access public
	/* @param  array ※参照渡し
	/* @param  number
	/* @param  number
	/* @return string
	 */
	public function getBetween(&$db_params, $bukenCountFrom, $bukenCountTo)
	{
		$db_params['bukenFrom'] = $bukenCountFrom;
		$db_params['bukenTo']   = $bukenCountTo;

		$sql  = ')T03_HEYA ) T03 where T03_DISP_ROW between :bukenFrom and :bukenTo';

		return $sql;
	}

	/**
	/* 物件一覧用SELECT句の取得（店舗から部屋検索）
	/*
	/* @access public
	/* @return string
	 */
	public function getSelectPhraseForShop($params)
	{
		// ｸｴﾘ文字列（Select句）
		$strQrySelect  = ' SELECT';
		$strQrySelect .= '     *';
		$strQrySelect .= ' FROM';
		$strQrySelect .= '     (SELECT';
		$strQrySelect .= '          ROWNUM AS T03_DISP_ROW';
		$strQrySelect .= '         ,T03_HEYA.*';

		// 2010/12/24 ランダム表示対応

		$strQrySelect .= '      FROM';
		$strQrySelect .= '         ( SELECT /*+ index(M03_SHOP PKM03_EKI_CD) */';
		$strQrySelect .= '              M05_SHOP.M05_TENPO_CD';
		$strQrySelect .= '             ,M05_SHOP.M05_TENPO_NAME';
		$strQrySelect .= '             ,M05_SHOP.M05_HOUZIN_CD';
		$strQrySelect .= '             ,M05_SHOP.M05_OEM';
		$strQrySelect .= '             ,M05_SHOP.M05_TENPO_TEL01';
		$strQrySelect .= '             ,M05_SHOP.M05_TENPO_TEL02';
		$strQrySelect .= '             ,M05_SHOP.M05_TENPO_YUUBIN';
		$strQrySelect .= '             ,M05_SHOP.M05_JYUUSHO_TEXT';
		$strQrySelect .= '             ,M05_SHOP.M05_TENPO_JYUUSHO_BIKOU';
		$strQrySelect .= '             ,M03_SHOP.M03_ENSEN_NAME';
		$strQrySelect .= '             ,M03_SHOP.M03_EKI_NAME';
		$strQrySelect .= '             ,M05_SHOP.M05_EIGYOU_ZIKAN_OPEN_H';
		$strQrySelect .= '             ,M05_SHOP.M05_EIGYOU_ZIKAN_OPEN_M';
		$strQrySelect .= '             ,M05_SHOP.M05_EIGYOU_ZIKAN_CLOSE_H';
		$strQrySelect .= '             ,M05_SHOP.M05_EIGYOU_ZIKAN_CLOSE_M';
		$strQrySelect .= '             ,M05_SHOP.M05_EIGYOU_ZIKAN_BIKOU';
		$strQrySelect .= '             ,M05_SHOP.M05_HOUZINMEI';
		$strQrySelect .= '             ,M05_SHOP.M05_TEIKYUUBI';
		$strQrySelect .= '             ,M05_SHOP.M05_TEIKYUUBI_BIKOU';
		$strQrySelect .= '             ,A06.A06_BUKKEN_CNT';
		for ($call_no=1; $call_no<=Apm_Config_Shop::CALLNOTE_NO_MAX; $call_no++) {
			$strQrySelect .= "         ,M93.M93_CONNECTION_NO".$call_no;
			$strQrySelect .= "         ,M93.M93_CONTROL_FLAG".$call_no;
		}
		$strQrySelect .= '             ,M93.M93_USE_KBN';
		$strQrySelect .= '             ,M93.M93_START_DATE';
		$strQrySelect .= '             ,M93.M93_DEL_DATE';
		$strQrySelect .= '             ,SUBSTR(M05S.M05_SERVICE_FLAG, 12, 1) AS INFOMATION_CENTER_FLAG';
		$strQrySelect .= '             ,CEIL(DBMS_RANDOM.VALUE*1000000) RANDOM';
		$strQrySelect .= '           FROM';
		$strQrySelect .= '           ( SELECT ';
		$strQrySelect .=                   $this->getQryhint($params);
		$strQrySelect .= '                 T03.T03_TENPO_CD';

		return $strQrySelect;
	}

	/**
	/* カウント用SELECT句の取得（店舗から部屋検索）
	/*
	/* @access public
	/* @return string
	 */
	public function getSelectCountForShop($params)
	{
		// ｸｴﾘ文字列（Select句）
		$strQrySelect  = ' SELECT';
		$strQrySelect .= '     count(T03_TENPO_CD) AS SHOP_COUNT';
		$strQrySelect .= ' FROM';
		$strQrySelect .= ' ( SELECT ';
		$strQrySelect .=         $this->getQryhint($params);
		$strQrySelect .= '       T03.T03_TENPO_CD';

		return $strQrySelect;
	}

	/**
	/* カウント用GROUP BY句の取得（店舗から部屋検索）
	/*
	/* @access public
	/* @return string
	 */
	public function getGroupByCountForShop()
	{
		// ｸｴﾘ文字列（Select句）
		$strQrySelect  = ' GROUP BY';
		$strQrySelect .= '     T03.T03_TENPO_CD) T03';

		return $strQrySelect;
	}

	/**
	/* FROM句を取得（店舗から部屋検索）
	/*
	/* @access public
	/* @return string
	 */
	public function getFromForShop()
	{
		$sql  = ' ,M05TENPO_INFO M05_SHOP';
		$sql .= ' ,M03EKI M03_SHOP';
		$sql .= ' ,A06TENPO_BUKKEN_COUNT A06';
		$sql .= ' ,M93CALLNOTE M93';		// 2013/08 WEBCALLING→CALLNOTE 切替
		$sql .= ' ,M05TENPO_SERVICE M05S';

		return $sql;
	}


	/**
	/* Where句を取得（店舗から部屋検索）
	/*
	/* @access public
	/* @return string
	 */
	public function getWhereForShop()
	{
		$sql  = ' WHERE';
		$sql .= '     M05_SHOP.M05_TENPO_CD   = T03.T03_TENPO_CD';
		$sql .= ' AND M05_SHOP.M05_EKI_CD01   = M03_SHOP.M03_EKI_CD(+)';
		$sql .= ' AND M05_SHOP.M05_ENSEN_CD01 = M03_SHOP.M03_ENSEN_CD(+)';
		$sql .= ' AND M05_SHOP.M05_TENPO_CD   = A06.A06_TENPO_CD(+)';
		$sql .= ' AND M05_SHOP.M05_TENPO_CD   = M93.M93_TENPO_CD(+)';
		$sql .= ' AND M05_SHOP.M05_TENPO_CD   = M05S.M05_TENPO_CD';
		//$sql .= ' AND M05_SHOP.M05_KOUKAI_FLAG = 1';

		return $sql;
	}
}
?>
